home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
0411.ZIP
/
STRIPPHI.C
< prev
next >
Wrap
Text File
|
1985-05-29
|
1KB
|
63 lines
/*
* Program to read a file, strip the high bits from each character,
* then discard non-printable characters.
*/
#include "stdio.h"
#define ASCIICHR 0x7f
main(argc,argv)
int argc;
char *argv[];
{
int c,
outfile,
infile;
if (argc == 1)
{
puts("\n");
puts("Syntax: STRIPPHI <infile> <outfile>\n");
puts("where infile is the filespec for the input data\n");
puts(" outfile is the filespec for the output data\n\n");
exit(0);
}
if (argc == 1)
{
puts("Author: Peter Townsend\n");
puts("Date: 28May85\n");
puts("Version: 1.0\n");
}
if ((infile = open(argv[1],0)) == -1)
{
printf("\nCannot open input file %s\n",argv[1]);
exit(1);
}
if (argc == 2)
{
printf("\nMissing Output Filename\n");
exit(1);
}
if (strcmp(argv[1],argv[2]) == 0)
{
printf("\nInput filename and output filename cannot be the same.\n");
exit(1);
}
if ((outfile = open(argv[2],1)) == -1)
{
if ((outfile = creat(argv[2])) == -1)
{
printf("\nCannot open/create output file %s\n",argv[2]);
exit(1);
}
}
while ((c = fgetc(infile)) != EOF)
{
c = (c & ASCIICHR);
if (isprint(c))
{
putc(c,outfile);
}
}
fclose(infile);
fclose(outfile);
exit(0);
}